home *** CD-ROM | disk | FTP | other *** search
/ Creative Review 28 / Creative-Review-CD-ROM-28.iso / pc / kungfu / assets / game.dir / 00035_Script_actor class < prev    next >
Text File  |  1997-08-08  |  7KB  |  290 lines

  1. -- actor class method
  2. -- --------------------------------------------------
  3. -- abstract superclass for baddy and player for v2.0b
  4. -- --------------------------------------------------
  5.  
  6. property data
  7. property type
  8. property ancestor
  9. property health
  10.  
  11. property cell
  12. property direction
  13.  
  14. property nextmove
  15. property nextmoveflag
  16.  
  17. property currentmove
  18.  
  19. -- --------------------------------------------------
  20. global gcell
  21. global gblocks
  22. global gstar
  23. global gsound
  24. global gkeytomove
  25. -- ==================================================
  26. -- new method
  27. -- --------------------------------------------------
  28. on new me, props
  29.   
  30.   minit me, props
  31.   return me
  32.   
  33. end mnew 
  34.  
  35. -- ==================================================
  36. -- minit method
  37. -- --------------------------------------------------
  38. on minit me, props
  39.   
  40.   --  put "in minit actor"
  41.   
  42.   set blockflag = false
  43.   set data = checkaprop ( props, #data,  #loony )
  44.   set health = checkaprop ( props, #health, 0 )
  45.   set type = checkaprop ( props, #type, #loony )
  46.   set direction = checkaprop ( props, #direction, #left )
  47.   set cell = checkaprop ( props, #cell, #nocell )
  48.   
  49.   set ancestor = new ( script "anim manager class" , props )
  50.   
  51.   --  put "out minit actor"
  52.   
  53. end minit
  54.  
  55. -- ==================================================
  56. -- mdispose me
  57. -- --------------------------------------------------
  58. on mdispose me
  59.   
  60.   --  put "in mdispose actor class"
  61.   
  62.   mdispose ancestor
  63.   set ancestor = 0
  64.   
  65.   --  put "in mdispose actor class"
  66.   
  67. end mdispose me
  68.  
  69. -- ==================================================
  70. -- mmovefinish method
  71. -- --------------------------------------------------
  72. on mmovefinish me
  73.   
  74.   -- put "in mmovefinish actor"
  75.   
  76.   set pixeloffset = 0
  77.   
  78.   case currentmove of 
  79.     #walkleft: 
  80.       mfinishwalk gcell, me, cell, #left
  81.       set move =  - 1
  82.     #walkright: 
  83.       mfinishwalk gcell, me, cell, #right
  84.       set move =  1
  85.     #jumpleft: 
  86.       set move =  - 8
  87.     #jumpright: 
  88.       set move =  + 8
  89.   end case
  90.   
  91.   set cell = cell + move
  92.   
  93.   set theloch = ( mcell2screen ( gcell, the cell of me ) )  
  94.   set theloc = point ( theloch, mgetfloor ( gcell ) )
  95.   set offset = ( mgetstartoffset ( gcell, the direction of me , data ) ) 
  96.   set theloc = theloc + offset
  97.   msetloc ( me, theloc )
  98.   
  99.   -- put "out mmovefinish actor"
  100.   
  101. end mmovefinish me
  102.  
  103. -- ==================================================
  104. -- msetcurrentmove method
  105. -- --------------------------------------------------
  106. on msetcurrentmove me, themove
  107.   
  108.   --  put "in msetcurrentmove"
  109.   
  110.   case themove of:
  111.     #jumpleft: mjump gcell me, cell, #left
  112.     #jumpright: mjump gcell me, cell, #right
  113.     #turnleft:  set direction = #left
  114.     #turnright: set direction = #right
  115.     #walkleft:  mstartwalk gcell, me, cell, #left
  116.     #walkright: mstartwalk gcell, me, cell, #right
  117.   end case
  118.   
  119.   set currentmove = themove
  120.   
  121.   --  put "repeatindex: " , repeatindex
  122.   --  put "currentmove: " , currentmove
  123.   --  put "currentrepeatflag: " , currentrepeatflag
  124.   
  125.   msetanim ancestor, currentmove, me
  126.   
  127.   --  put "out msetcurrentmove"
  128.   
  129. end msetcurrentmove 
  130.  
  131. -- ==================================================
  132. -- mhit method
  133. -- --------------------------------------------------
  134. on mhit me, starloc
  135.   
  136.   --  put "in mhit actor" , me
  137.   
  138.   set others = mcheck ( gcell, cell, direction )
  139.   
  140.   if count ( others ) then 
  141.     set other = getat ( others, 1 )
  142.     
  143.     if mhurt ( other, currentmove ) then
  144.       mslap gsound, data
  145.       mstart gstar, the data of other, ( the loc of me + starloc )
  146.       return true
  147.     end if
  148.     
  149.   end if
  150.   
  151.   return false
  152.   
  153.   put "out mhit actor"
  154.   
  155. end mhit
  156.  
  157. -- ==================================================
  158. -- mcheckblock method
  159. -- --------------------------------------------------
  160. on mcheckblock me, attackmove
  161.   
  162.   set myblocks = getaprop ( gblocks, type )
  163.   set validblocks = getaprop ( myblocks , attackmove )
  164.   
  165.   if not ( listp ( validblocks ) ) then return false
  166.   
  167.   if getone ( validblocks, currentmove ) then return true
  168.   else return false
  169.   
  170. end mcheckblock
  171.  
  172. -- ==================================================
  173. -- mcheckhurt method
  174. -- --------------------------------------------------
  175. on mcheckhurt me, attackmove, starloc,
  176.   
  177.   --  put "in mhurt actor", health, damage
  178.   
  179.   if not ( mcheckblock ( me, attackmove ) ) then
  180.     
  181.     mdamage me, 10
  182.     
  183.     return true
  184.     
  185.   end if
  186.   
  187.   return false
  188.   
  189.   --  put "nextmove: " , nextmove
  190.   
  191.   --  put "out mhurt actor" , health
  192.   
  193. end mcheckhurt
  194.  
  195. -- ==================================================
  196. -- mkeytomove method
  197. -- --------------------------------------------------
  198. on mkeytomove me, thekey
  199.   
  200.   set anims = getaprop ( gkeytomove, direction)
  201.   set themove = getaprop ( anims, thekey )
  202.   
  203.   return themove
  204.   
  205. end mkeytomove
  206.  
  207. -- ==================================================
  208. -- mgetcurrentkey method
  209. -- --------------------------------------------------
  210. on mgetcurrentkey me
  211.   
  212.   return mmovetokey ( me, currentmove )
  213.   
  214. end mgetcurrentkey
  215.  
  216. -- ==================================================
  217. -- mmovetokey method
  218. -- --------------------------------------------------
  219. on mmovetokey me, move
  220.   
  221.   set movelist = getaprop ( gkeytomove, direction )
  222.   set key = getone ( movelist, move)
  223.   
  224.   return key
  225.   
  226. end mmovetokey 
  227.  
  228. -- ==================================================
  229. -- mcheckwalk method
  230. -- --------------------------------------------------
  231. on mcheckwalk me, newmove
  232.   
  233.   case newmove of
  234.     #walkleft: 
  235.       set who = mcheck ( gcell, cell ,  #left )
  236.       if not ( count ( who ) = 0 ) then set newmove = #idleleft
  237.     #walkright: 
  238.       set who = mcheck ( gcell, cell, #right )
  239.       if not ( count ( who ) = 0 ) then set newmove = #idleright
  240.   end case
  241.   
  242.   return newmove
  243.   
  244. end mcheckwalk
  245.  
  246. -- ==================================================
  247. -- mdamage method
  248. -- --------------------------------------------------
  249. on mdamage me, thedamage
  250.   
  251.   set health = health - thedamage
  252.   
  253.   if health <= 0 then 
  254.     set nextkey = #die
  255.     mstartdie me
  256.   else set nextkey = #hit
  257.   
  258.   mabort me
  259.   
  260.   msetcurrentmove me, mkeytomove ( me , nextkey )
  261.   
  262. end mdamage
  263.  
  264. -- ==================================================
  265. -- mstartdie method
  266. -- --------------------------------------------------
  267. on mstartdie me 
  268.   
  269.   --  put "in mstartdie actor"
  270.   
  271.   --  put "out mstartdie actor"
  272.   
  273. end mstartdie 
  274.  
  275. -- ==================================================
  276. -- mabort method
  277. -- --------------------------------------------------
  278. on mabort me
  279.   
  280.   --  put "in mabort actor class :"
  281.   
  282.   set nextmoveflag = false
  283.   
  284.   mmovefinish me
  285.   mabort ancestor
  286.   
  287.   --  put "out mabort actor class :"
  288.   
  289. end mabort
  290.